using System;
using System.Windows.Forms;

using FreeFlow.Administration;
using FreeFlow.WinFormsControls;

namespace FreeFlowAdministrator
{
	/// <summary>
	/// Summary description for FormAdaptor.
	/// </summary>
	public class FormAdaptor : Adaptor
	{
    private FreeFlow.Administration.Form form;
		public FormAdaptor(FreeFlow.Administration.Form form)
		{
			this.form = form;
    }

    public override void AddChildren(System.Windows.Forms.TreeNode node)
    {
      foreach (Field field in form.Fields)
      {
        TreeNode childNode = TreeNodeFactory.CreateTreeNode(new FieldAdaptor(field));
        node.Nodes.Add(childNode);
      }
    }

    public override Control GetRenderer()
    {
      FormControl control = new FormControl();
      control.LoadForm(form);
      return control;
    }

    public override int ImageIndex
    {
      get
      {
        return 3;
      }
    }

    public override string Text
    {
      get
      {
        return form.Name;
      }
    }

    public override object Object
    {
      get
      {
        return form;
      }
    }
  }
}
